//
//  RelatedArray.m
//  TianXiaShi
//
//  Created by CongCong on 15-7-14.
//  Copyright (c) 2015年 CongCong. All rights reserved.
//

#import "RelatedArray.h"
#import "AFNetworking.h"
#import "LCSubMemItemModel.h"
#define kUrl @"http://vcsp.ifeng.com/vcsp/appData/getGuidRelativeVideoList.do?guid=%@&pageSize=20"
@implementation RelatedArray
+(void)relateDataArrayWith:(NSString *)guid Block:(Block)block
{
    NSMutableArray *dataArray = [NSMutableArray array];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager GET:[NSString stringWithFormat:kUrl,guid] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSArray *contentArray = dict[@"guidRelativeVideoInfo"];
        for (NSDictionary *detailDict in contentArray) {
            LCSubMemItemModel *model = [[LCSubMemItemModel alloc]initWithDictionary:detailDict error:nil];
            [dataArray addObject:model];
        }
        block(dataArray);
    }
         failure:^(AFHTTPRequestOperation *operation, NSError *error) {
             NSLog(@"下载失败");
         }];

}
@end
